package com.student.foodAfter.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * ClassName: RedisService <br/>
 * Description: <br/>
 * date: 2023/1/15 19:14<br/>
 *
 * @author 李林雨 <br/>
 * @since JDK 8
 */
@Service
public class RedisService {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

//
//    //设置ip 封了该ip
//    public void setIp(String ip){
//        redisUtils.set("restrictionIP",ip);
//        String restrictionIP = redisUtils.get("restrictionIP");
//        System.out.println("打印从redis中获取的ip"+restrictionIP);
//    }

    //qq邮箱发送验证码，给该邮箱
    public void setUserCode(String username,String code){
        stringRedisTemplate.opsForValue().set(username,code,30, TimeUnit.SECONDS);
    }
    public String getUserCode(String username){
        String s = stringRedisTemplate.opsForValue().get(username);
        return s;
    }
}
